<?php    
    @session_start();
    require_once("inc/db.class.php");
    require("loginFunction.php");
    $id=mysql_escape_string($_POST['email']);                    // Assigned the post variable new variable $userid
    $password=mysql_escape_string($_POST['password']);           // Assigned the post variable new variable $userid
    if($id=='Email' && $password=='' || $password==' ')
    {
        header('location: login.php?m=e&p=e');	
    }
    else if($id=='' || $id==' ' || $id=='Email')
    {
        header('location: login.php?m=e');	
    }
    else if($password=='' || $password==' ')
    {
        header('location: login.php?p=e');	
    }
    else
    {
        $check=login($id, $password); // call the login() function
		
		echo "check=".$check;
        if($check=='allow')
        {
            $_SESSION['login']="true";
            if(isset($_SESSION['redirect']))
            {
                header("location: ".$_SESSION['redirect']);  
            }
            else{
                if($_SESSION['user_role']==1)
                    header("location: admin-panel.php");
                elseif($_SESSION['user_role']==2)
                    header("location: index.php?m=s");
                else
					header('location: login.php?p=e');	
            }
        }
        else
        //echo "id=".$id. "pass=".$password."check=".$check;
        header('location: login.php?p=n');
}
?>